package com.yueka.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yueka.pojo.R;
import com.yueka.pojo.entity.base.MusicScore;
import com.yueka.pojo.param.MusicScorePageParam;
import com.yueka.pojo.param.MusicScoreSaveParam;
import com.yueka.pojo.vo.MusicScoreVO;
import com.yueka.service.MusicScoreService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 曲谱表 前端控制器
 * </p>
 *
 * @author D&M
 * @since 2025-10-20
 */
@RestController
@RequestMapping("/musicScore")
public class MusicScoreController {

    @Resource
    private MusicScoreService musicScoreService;

    @PostMapping("/save")
    public R<Void> save(@Validated @RequestBody MusicScoreSaveParam param) {
        musicScoreService.saveScore(param);
        return R.success();
    }

    @PostMapping("/detail/{id}")
    public R<MusicScoreVO> detail(@PathVariable Integer id) {
        return R.success(musicScoreService.detail(id));
    }

    @PostMapping("/delete/{id}")
    public R<Void> delete(@PathVariable Integer id) {
        musicScoreService.delete(id);
        return R.success();
    }

    @PostMapping("/pageList")
    public R<Page<MusicScore>> pageList(@Validated @RequestBody MusicScorePageParam param) {
        return R.success(musicScoreService.pageList(param));
    }

}

